package com.heal.error;

import com.heal.entity.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

  @ExceptionHandler(value = BusinessException.class)
  public ResponseEntity<Object> businessExceptionHandler(
      HttpServletRequest request, BusinessException e) {
    return ErrorInfo.response(e.getErrorCode(), "没有错误信息");
  }
}
